package com.homelock.common.enumeration;

public enum ServiceTypeEnum {
    MESSAGE("Message",1),
    Alarm("Alarm",2);
    private String code;
    private Integer type;
    private ServiceTypeEnum(String code,Integer type){
        this.code = code;
        this.type = type;
    }

    public String getCode() {
        return code;
    }

    public Integer getType() {
        return type;
    }

    public static ServiceTypeEnum val(String code) {
        for(ServiceTypeEnum s : values()) {    //values()方法返回enum实例的数组
            if(code.equals(s.getCode()))
                return s;
        }
        return null;
    }

    public static ServiceTypeEnum valType(int  type) {
        for(ServiceTypeEnum s : values()) {    //values()方法返回enum实例的数组
            if(type == s.getType())
                return s;
        }
        return null;
    }

}
